package org.yzh.web.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.yzh.commons.util.PageResultDTO;
import org.yzh.commons.util.Ret;
import org.yzh.web.request.PersonnelAlarmAddRequest;
import org.yzh.web.request.PersonnelAlarmPageSearchRequest;
import org.yzh.web.response.PersonnelAlarmPageSearchResponse;
import org.yzh.web.service.PersonnelAlarmService;
@RestController
@Slf4j
@Tag( name = "人员警告接口")
@RequestMapping("/alarm")
public class PersonnelAlarmController {

    @Autowired
    private PersonnelAlarmService personnelAlarmService;

    @Operation(summary = "新增人员报警")
    @PostMapping("/save")
    public Ret save(@RequestBody PersonnelAlarmAddRequest personnelAlarmAddRequest) {
        personnelAlarmService.save1(personnelAlarmAddRequest);
        return Ret.success("新增成功");
    }


    @Operation(summary = "编辑人员报警")
    @PostMapping("/update")
    public Ret update(@RequestBody PersonnelAlarmAddRequest personnelAlarmAddRequest) {
        personnelAlarmService.update(personnelAlarmAddRequest);
        return Ret.success("编辑成功");
    }

    @Operation(summary = "删除人员报警")
    @PostMapping("/remove/{id}")
    public Ret remove(@PathVariable("id") Long id) {
        personnelAlarmService.delete(id);
        return Ret.success("删除成功");
    }

    @Operation(summary = "查询人员报警")
    @PostMapping("/query")
    public Ret<PageResultDTO<PersonnelAlarmPageSearchResponse>>  query(@RequestBody PersonnelAlarmPageSearchRequest personnelAlarmPageSearchRequest) {
        PageResultDTO<PersonnelAlarmPageSearchResponse> resultDTO = personnelAlarmService.select(personnelAlarmPageSearchRequest);
        return Ret.success(resultDTO);
    }
}
